<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.1/axios.js"></script>
</head>

<body>
    <button>发送请求</button>
    <script>
        // 获取按钮
        let btns = document.querySelectorAll('button');

        //定义2个axios调用 

        // 监听2个axios执行结果及定义回调
        btns[0].onclick = function() {
            let a1 = axios('http://api.zhibao.com/movies/1213');
            let a2 = axios('http://api.zhibao.com/movies/2');
            let a3 = axios('http://api.zhibao.com/movies/9');

            // console.log(a1, a2, a3);


            // 所有的请求都成功，就返回成功的promise，结果值为成功的值的数组
            // 只要有一个请求失败，就返回失败的promise，结果值就是错误对象
            let data = axios.all([a1, a2, a3]);

            console.log(data);
        }
    </script>
</body>

</html>